package com.leetcode.partition5;

/**
 * @author `RKC`
 * @date 2021/10/18 8:15
 */
public class LC476数字的补数 {

    public static int findComplement(int num) {
        String a = Integer.toBinaryString(num);
        String b = Integer.toBinaryString(~num);
        return Integer.parseInt(b.substring(32 - a.length()), 2);
    }

    public static void main(String[] args) {
        System.out.println(findComplement(1));
//        System.out.println(Integer.parseInt("101", 2));
    }
}
